package fr.pascal.client.mvp;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;

import fr.pascal.client.ClientFactory;
import fr.pascal.client.activity.ListActivity;
import fr.pascal.client.place.DetailPlace;
import fr.pascal.client.place.ListPlace;

public class ListActivityMapper implements ActivityMapper {
	
	private ClientFactory clientFactory;
	
	public ListActivityMapper(ClientFactory clientFactory) {
		this.clientFactory = clientFactory;
	}

	@Override
	public Activity getActivity(Place place) {
		if (place instanceof DetailPlace) {
			return new ListActivity(clientFactory, (DetailPlace) place);
		} else if (place instanceof ListPlace) {
			return new ListActivity(clientFactory);
		} 
		return null;
	}
}
